package com.code.demo.ui.guide;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;

import com.code.demo.R;
import com.code.demo.ui.MainActivity;
import com.code.demo.ui.base.BaseActivity;
import com.tmall.ultraviewpager.UltraViewPager;

import static com.code.demo.config.Colors.IndicatorNormal;
import static com.code.demo.config.Colors.IndicatorSelect;


/**
 * Created by yangliguo on 2018/3/11.
 */

public class GuideActivity extends BaseActivity {

    private UltraViewPager vp;
    private GuidePagerAdapter adapter;

    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            startActivity(new Intent(GuideActivity.this, MainActivity.class));
            finish();
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);

        vp = (UltraViewPager) findViewById(R.id.ultra_view_pager);
        vp.setScrollMode(UltraViewPager.ScrollMode.HORIZONTAL);
        adapter = new GuidePagerAdapter(false);
        adapter.setData(mHandler);
        vp.setAdapter(adapter);

        vp.initIndicator();
        vp.getIndicator().setOrientation(UltraViewPager.Orientation.HORIZONTAL)
                .setFocusColor(IndicatorSelect)
                .setNormalColor(IndicatorNormal)
                .setMargin(0,0,0,50)
                .setRadius(20);
        vp.getIndicator().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
        vp.getIndicator().build();

        vp.setInfiniteLoop(false);
    }

}